<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * Ajax Get Node Info action
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 23.04.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxGetNodeInfo
    ****
    * This class will return node information preformatted
    * by the ajax/nodeinfo.html template.
    ****
    * @package ajax
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 10.05.2005
    * @copyright essentialmind.com 2005
    ***/
    class ajaxGetNodeInfo extends ajaxAction{

        function process(){
            $id = (int)$_REQUEST['id'];
            
            //is this a call for the root node?
            if($id == 0){
                $id = $this->db->getOne("SELECT id FROM structure WHERE parent_id IS NULL");
            }
            
            $this->smarty->assign("nodel",$_REQUEST['nodel']);
            $data = $this->db->getRow("SELECT 
                                                                s.url, 
                                                                s.id, 
                                                                om.owner_uid AS uid, 
                                                                ua.login AS uname,
                                                                om.owner_gid AS gid, 
                                                                ug.name AS gname,
                                                                path_cache AS path, 
                                                                dt.name AS type,
                                                                dt.codeset AS codeset,
                                                                om.title AS title,
                                                                om.created AS intime,
                                                                om.modified AS modtime
                                                            FROM structure AS s 
                                                            LEFT JOIN datatype    AS dt ON s.node_type = dt.id 
                                                            LEFT JOIN objectmap   AS om ON s.id = om.nodeid
                                                            LEFT JOIN user_access AS ua ON om.owner_uid = ua.id
                                                            LEFT JOIN user_group  AS ug ON om.owner_gid = ug.id 
                                                            WHERE s.id = $id AND om.version = 1");
                                                            
            $this->smarty->assign("data", $data);                                                

            $controller = adminNodeFactory::cast($data['codeset'],$this->db,$this->smarty,$this->Log);
            
            //backwards compatible bro
            if(method_exists($controller, 'sidebarInfo')){
                $this->smarty->assign('sidebarInfo', $controller->sidebarInfo());
            }
            

            $this->r->html = $this->smarty->preFetch('ajax'.DIRECTORY_SEPARATOR.'nodeinfo.html');
        }
    }
?>